*Analysis of effect of intervention on coverage

cap log close

global path = "****"
local name= "coverage_tables"
local date = "051620"
global logname = "$path/`name'_`date'.log"

clear
set more off
set matsize 11000
cd "$path"
log using "$logname", replace

use "$path/Data/penalty_sample_prepcode.dta", clear

replace age_2017=0 if age_2017<0

*create control variables
gen cov2016_11 = (covered2016 - any_dec == 11)
gen age_45_64 = age_2017 < 65 & age_2017 >= 45
gen self_prepared = (prep_tin_flag == "")
gen no_botched_rollout = inlist(state,"CA","CO","CT","DC","KY","MN","NY","RI","WA")
gen botched_rollout = (no_botched_rollout == 0)

*Table:	Effect of Treatment on Coverage (overall, all16, notall16)

*Panel A: All ages
				
*Column 1: any_coverage1718 (overall)
reg any_covered1718 treatment, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/cov_effect_`date'.ster", replace

*Column 2: coverage1718 (overall)
reg covered1718 treatment, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_effect_`date'.ster", append

*Column 3:  any_coverage1718 (all16)
reg any_covered1718 treatment if cov2016_11 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/cov_effect_`date'.ster", append

*Column 4: coverage1718 (all16)
reg covered1718 treatment if cov2016_11 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_effect_`date'.ster", append

*Column 5: any_coverage1718 (notall16)
reg any_covered1718 treatment if notall16 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/cov_effect_`date'.ster", append

*Column 6:  coverage1718 (notall16)
reg covered1718 treatment if  notall16 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_effect_`date'.ster", append

*Panel B: Ages 45-64
				
*Column 1: any_coverage1718 (overall)
reg any_covered1718 treatment if age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/cov_effect_`date'.ster", append

*Column 2: coverage1718 (overall)
reg covered1718 treatment if age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_effect_`date'.ster", append

*Column 3:  any_coverage1718 (all16)
reg any_covered1718 treatment if cov2016_11 == 1 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/cov_effect_`date'.ster", append

*Column 4: coverage1718 (all16)
reg covered1718 treatment if cov2016_11 == 1 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_effect_`date'.ster", append

*Column 5: any_coverage1718 (notall16)
reg any_covered1718 treatment if notall16 == 1 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/cov_effect_`date'.ster", append

*Column 6:  coverage1718 (notall16)
reg covered1718 treatment if  notall16 == 1 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_effect_`date'.ster", append


		
*Table: Coverage Effect by Type of Coverage 

cap erase "$path/type_of_coverage_`date'.ster"
cap erase "$path/type_of_coverage_4564_`date'.ster"


foreach var in exchange medicaid esi off_exchange va medicare{

gen `var'1718 = `var'2017 + `var'2018
gen any_`var'1718 = (`var'1718 > 0 )

*Panel A: All Ages

reg `var'1718 treatment if notall16 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/type_of_coverage_`date'.ster", append

reg any_`var'1718 treatment if notall16 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/type_of_coverage_`date'.ster", append


*Panel B: Ages 45-64
reg `var'1718 treatment if notall16 == 1 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/type_of_coverage_4564_`date'.ster", append

reg any_`var'1718 treatment if notall16 == 1 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)&treatment==0
estadd scalar ymean=r(mean)*100
estimates save "$path/type_of_coverage_4564_`date'.ster", append
}


*Table: Heterogeneity - Gender, Marital Status, Tax Prep Method, Exchange Rollout (Intensive Margin)

*Panel A: All Ages

*Column 1: Male
reg covered1718 treatment if  notall16 == 1 & male == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_1_`date'.ster", replace

*Column 2: Female
reg covered1718 treatment if  notall16 == 1 & male == 0, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_1_`date'.ster", append

*Column 3: Married
reg covered1718 treatment if  notall16 == 1 & married == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_1_`date'.ster", append

*Column 4: Unmarried
reg covered1718 treatment if  notall16 == 1 & married == 0, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_1_`date'.ster", append

*Column 5: Self-Prepared Returns
reg covered1718 treatment if  notall16 == 1 & self_prepared == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_1_`date'.ster", append

*Column 6: Professionally Prepared Returns
reg covered1718 treatment if  notall16 == 1 & self_prepared == 0, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_1_`date'.ster", append

*Column 7: Succesful Exchange Rollout
reg covered1718 treatment if  notall16 == 1 & botched_rollout == 0, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_1_`date'.ster", append

*Column 8: Botched Exchange Rollout 
reg covered1718 treatment if  notall16 == 1 & botched_rollout == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_1_`date'.ster", append

*Panel B: Ages 45-64

*Column 1: Male
reg covered1718 treatment if  notall16 == 1 & male == 1 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_45_64_1_`date'.ster", replace

*Column 2: Female
reg covered1718 treatment if  notall16 == 1 & male == 0 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_45_64_1_`date'.ster", append

*Column 3: Married
reg covered1718 treatment if  notall16 == 1 & married == 1 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_45_64_1_`date'.ster", append

*Column 4: Unmarried
reg covered1718 treatment if  notall16 == 1 & married == 0 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_45_64_1_`date'.ster", append

*Column 5: Self-Prepared Returns
reg covered1718 treatment if  notall16 == 1 & self_prepared == 1 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_45_64_1_`date'.ster", append

*Column 6: Professionally Prepared Returns
reg covered1718 treatment if  notall16 == 1 & self_prepared == 0 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_45_64_1_`date'.ster", append

*Column 7: Succesful Exchange Rollout
reg covered1718 treatment if  notall16 == 1 & botched_rollout == 0 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_45_64_1_`date'.ster", append

*Column 8: Botched Exchange Rollout 
reg covered1718 treatment if  notall16 == 1 & botched_rollout == 1 & age_45_64 == 1, cl(tin)
eststo
estadd scalar nobs e(N)
summ `e(depvar)' if e(sample)& treatment==0
estadd scalar ymean=r(mean)
estimates save "$path/cov_hetgen_45_64_1_`date'.ster", append


			
log close

